<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">

				<el-form-item label="运营商" prop="operatoruid">
					<el-select v-model="filters.operatoruid" clearable placeholder="请选择运营商">
						<el-option value="0" label="全部">全部</el-option>
						<el-option
								v-for="item in operator"
								:key="item.operatoruid"
								:label="item.operatorname"
								:value="item.operatoruid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="省份" prop="provinceuuid">
					<el-select v-model="filters.provinceuuid" clearable placeholder="请选择省份">
						<el-option value="0" label="全部">全部</el-option>
						<el-option
								v-for="item in info"
								:key="item.provinceuuid"
								:label="item.provincename"
								:value="item.provinceuuid">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="业务类型" prop="busuuid"  >
					<el-select v-model="filters.busuuid" clearable placeholder="请选择业务类型"   >
						<el-option value="0" label="全部" >全部</el-option>
						<el-option
								v-for="item in bus"
								:key="item.busuuid"
								:label="item.busname"
								:value="item.busuuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="供货商" prop="useruuid" >
					<el-select v-model="filters.useruuid" clearable placeholder="请选择供货商"  @change="userChange" filterable >
						<el-option value="0" label="全部" >全部</el-option>
						<el-option
								v-for="item in users"
								:key="item.user.useruuid"
								:label="item.user.username"
								:value="item.user.useruuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="有效期" prop="validity">
					<el-select v-model="filters.validity" clearable placeholder="请选择运有效期">
						<el-option value="0" label="全部">全部</el-option>
						<el-option value="1" label="30天">30天</el-option>
						<el-option value="2" label="当月">当月</el-option>
					</el-select>
				</el-form-item>
				<el-form-item>
					<el-input v-model="filters.productCode" clearable placeholder="产品编码"></el-input>
				</el-form-item>
				<el-form-item>
					<el-input v-model="filters.upfacevalue" clearable placeholder="面值"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="findPageProduct">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="exportUpProduct">导出</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="handleAdd">新增</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="products" highlight-current-row v-loading="listLoading" border max-height="620"  style="width: 100%;">
			<el-table-column type="index" width="80" label="编号">
			</el-table-column>
			<el-table-column prop="operators.operatorname" width="100px" label="运营商" >
			</el-table-column>
			<el-table-column prop="provincialInformation.provincename" label="省份"    >
			</el-table-column>
			<el-table-column prop="cityName" label="地市">
			</el-table-column>
			<el-table-column prop="businessType.busname" width="110px"  label="业务类型" show-overflow-tooltip   >
			</el-table-column>
			<el-table-column prop="user.username" width="130px"  label="供货商" show-overflow-tooltip  >
			</el-table-column>
			<el-table-column prop="productCode" label="产品编码" width="100px" show-overflow-tooltip >
			</el-table-column>
			<el-table-column prop="productName"  width="110px" label="产品名称" show-overflow-tooltip>
			</el-table-column>
			<el-table-column prop="price"  width="110px" label="产品原价">
			</el-table-column>
			<el-table-column prop="upfacevalue"  width="100px" label="产品面值" :formatter="productType">
			</el-table-column>
			<el-table-column prop="discount" label="实际折扣"  width="100px"    >
			</el-table-column>
			<el-table-column prop="discountAmount" label="实际金额"  width="110px"    >
			</el-table-column>
			<el-table-column prop="deduct" label="扣款折扣"  width="100px"    >
			</el-table-column>
			<el-table-column prop="deductAmount" label="扣款金额"  width="110px"    >
			</el-table-column>
			<el-table-column prop="validity" label="有效期":formatter="fastchargevalidity" >
			</el-table-column>
			<el-table-column prop="status" label="状态"   :formatter="status"  >
			</el-table-column>
			<el-table-column prop="remark" label="备注"   >
			</el-table-column>
			<el-table-column label="压单" >
				<template scope="scope">
					<el-switch
							v-model="scope.row.pressOrder"
							active-text=""
							inactive-text="">
					</el-switch>
				</template>
			</el-table-column>
			<el-table-column label="人工" >
				<template scope="scope">
					<el-switch
							v-model="scope.row.artificial"
							active-text=""
							inactive-text="">
					</el-switch>
				</template>
			</el-table-column>
			<el-table-column label="操作"  fixed="right" width="150">
				<template scope="scope">
					<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
					<el-button size="small" @click="handleEnable(scope.$index, scope.row)">{{scope.row.status == 2 ? '启用' : '禁用'}}</el-button>
				</template>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-pagination
				@current-change="handleCurrentChange"
				@size-change="handleSizeChange"
				layout="total,sizes,prev, pager, next"
				:total="total">
		</el-pagination>
		<!--编辑界面-->
		<el-dialog title="编辑供货商产品" v-model="editFormVisible" :close-on-click-modal="false">
			<el-form :model="editForm" label-width="100px"  :inline="true"  :rules="editFormRules" ref="editForm">
				<el-form-item label="运营商" prop="operatoruid"  >
					<el-select v-model="editForm.operatoruid" placeholder="请选择运营商"  >
						<el-option
								v-for="item in operator"
								:key="item.operatoruid"
								:label="item.operatorname"
								:value="item.operatoruid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="省份" prop="provinceuuid"  >
					<el-select v-model="editForm.provinceuuid" placeholder="请选择省份" >
						<el-option
								v-for="item in info"
								:key="item.provinceuuid"
								:label="item.provincename"
								:value="item.provinceuuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="业务类型" prop="busuuid"  >
					<el-select v-model="editForm.busuuid" placeholder="请选择业务类型"   >
						<el-option
								v-for="item in bus"
								:key="item.busuuid"
								:label="item.busname"
								:value="item.busuuid">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="供货商" prop="useruuid" >
					<el-select v-model="editForm.useruuid" placeholder="请选择供货商"   >
						<el-option
								v-for="item in users"
								:key="item.user.useruuid"
								:label="item.user.username"
								:value="item.user.useruuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="产品名称" prop="productName">
					<el-input v-model="editForm.productName" placeholder="请输入产品名称"></el-input>
				</el-form-item>
				<el-form-item label="产品编码" prop="productCode" >
					<el-input v-model="editForm.productCode" placeholder="请输入产品编码"></el-input>
				</el-form-item>
				<el-form-item label="产品原价" prop="price" placeholder="请输入产品原价">
					<el-input v-model="editForm.price" v-on:input="discountChangeEdit"></el-input>
				</el-form-item>
				<el-form-item label="产品面值"  prop="upfacevalue" placeholder="请输入产品面值">
					<el-input v-model="editForm.upfacevalue"  ></el-input>
				</el-form-item>
				<el-form-item label="实际折扣"  prop="discount" placeholder="请输入实际折扣">
					<el-input v-model="editForm.discount"   v-on:input="discountChangeEdit"  ></el-input>
				</el-form-item>
				<el-form-item label="实际金额" prop="discount" placeholder="请输入实际金额">
					<el-input v-model="editForm.discountAmount" :disabled="true"></el-input>
				</el-form-item>
				<el-form-item label="扣款折扣" prop="deduct" placeholder="请输入扣款折扣,移动折扣">
					<el-input v-model="editForm.deduct"  v-on:input="deductChangeEdit" ></el-input>
				</el-form-item>
				<el-form-item label="扣款金额" prop="deductAmount"  placeholder="请输入扣款金额,移动扣款">
					<el-input v-model="editForm.deductAmount" :disabled="true"></el-input>
				</el-form-item>


				<el-form-item label="有效期" prop="validity">
					<el-select v-model="editForm.validity" placeholder="请选择运有效期">
						<el-option value="0" label="全部">全部</el-option>
						<el-option value="1" label="30天">30天</el-option>
						<el-option value="2" label="当月">当月</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="备注">
					<el-input type="textarea" v-model="editForm.remark"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="editFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
			</div>
		</el-dialog>

		<!--新增界面-->
		<el-dialog title="新增供货商产品" size="small" v-model="addFormVisible" :close-on-click-modal="false">
			<el-form :model="addForm" label-width="100px" :inline="true"  :rules="addFormRules" ref="addForm">
				<el-form-item label="运营商" prop="operatoruid"  >
					<el-select v-model="addForm.operatoruid" placeholder="请选择运营商"    >
						<el-option
								v-for="item in operator"
								:key="item.operatoruid"
								:label="item.operatorname"
								:value="item.operatoruid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="省份" prop="provinceuuid"  >
					<el-select v-model="addForm.provinceuuid" placeholder="请选择省份" >
						<el-option
								v-for="item in info"
								:key="item.provinceuuid"
								:label="item.provincename"
								:value="item.provinceuuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="业务类型" prop="busuuid"  >
					<el-select v-model="addForm.busuuid" placeholder="请选择业务类型"   >
						<el-option
								v-for="item in bus"
								:key="item.busuuid"
								:label="item.busname"
								:value="item.busuuid">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="供货商" prop="useruuid" >
					<el-select v-model="addForm.useruuid" placeholder="请选择供货商"   >
						<el-option
								v-for="item in users"
								:key="item.user.useruuid"
								:label="item.user.username"
								:value="item.user.useruuid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="产品名称" prop="productName">
					<el-input v-model="addForm.productName" placeholder="请输入产品名称"></el-input>
				</el-form-item>
				<el-form-item label="产品编码" prop="productCode">
					<el-input v-model="addForm.productCode" placeholder="请输入产品编码"></el-input>
				</el-form-item>
				<el-form-item label="产品原价" prop="price" placeholder="请输入产品原价">
					<el-input v-model="addForm.price"  v-on:input="discountChangeAdd" ></el-input>
				</el-form-item>
				<el-form-item label="产品面值"  prop="upfacevalue" placeholder="请输入产品面值">
					<el-input v-model="addForm.upfacevalue"  ></el-input>
				</el-form-item>
				<el-form-item label="实际折扣"  prop="discount" placeholder="请输入实际折扣">
					<el-input v-model="addForm.discount"  v-on:input="discountChangeAdd" ></el-input>
				</el-form-item>
				<el-form-item label="实际金额" prop="discount" placeholder="请输入实际金额">
					<el-input v-model="addForm.discountAmount" :disabled="true"></el-input>
				</el-form-item>
				<el-form-item label="扣款折扣" prop="deduct" placeholder="请输入扣款折扣,移动折扣">
					<el-input v-model="addForm.deduct" v-on:input="deductChangeAdd" ></el-input>
				</el-form-item>
				<el-form-item label="扣款金额" prop="deductAmount"  placeholder="请输入扣款金额,移动扣款">
					<el-input v-model="addForm.deductAmount" :disabled="true"></el-input>
				</el-form-item>

				<el-form-item label="有效期" prop="validity">
					<el-select v-model="addForm.validity" placeholder="请选择运有效期">
						<el-option value="0" label="全部">全部</el-option>
						<el-option value="1" label="30天">30天</el-option>
						<el-option value="2" label="当月">当月</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="备注">
					<el-input type="textarea" v-model="addForm.remark"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="addFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="addUpProduct" :loading="addLoading">提交</el-button>
			</div>
		</el-dialog>
	</section>
</template>

<script>
	import util from '../../common/js/util'
	//import NProgress from 'nprogress'
	import { findPageProduct,findOpeProBusShop ,findByProvince,addUpProduct,findOneUpProduct,
		updateUpProduct,findAllUpShopInfo,productEnable,upfindlist,exportUpProduct,
		updateProductArtificial,updateProductPressOrder} from '../../api/api';
    import ElOption from "../../../node_modules/element-ui/packages/select/src/option.vue";

	export default {
        components: {ElOption},
        data() {
			return {
				filters: {
					name: '',
                    busuuid:'',
                    useruuid:'',
                    productCode:'',
                    provinceuuid:'',
                    operatoruid:'',
                    validity:'',
					upfacevalue:''
				},
                products: [],
                total: 0,
                start:0,
                pageSize:10,
				listLoading: false,
				editFormVisible: false,//编辑界面是否显示
				editLoading: false,
				editFormRules: {
                    operatoruid: [
                        { required: true, message: '请选择运营商', trigger: 'blur' }
                    ],
                    provinceuuid: [
                        { required: true, message: '请选择省份', trigger: 'blur' }
                    ],
                    busuuid: [
                        { required: true, message: '请选择业务类型', trigger: 'blur' }
                    ],
                    useruuid: [
                        { required: true, message: '请选择渠道商', trigger: 'blur' }
                    ],
                    upfacevalue :[
                        { required: true, message: '请输入产品面值,如果是话费则是对应的充值原价,如果是流量则是xxM', trigger: 'blur' }
                    ],
                    productCode :[
                        { required: true, message: '请输入产品名称', trigger: 'blur' }
                    ],
                    discount :[
                        { required: true, message: '请输入折扣', trigger: 'blur' },
                        {min: 1, max: 8, message: '长度在 1 到 3 个字符', trigger: 'blur'},
                    ],
                    fastchargetype :[
                        { required: true, message: '请选择快慢充类型', trigger: 'blur' }
                    ],price:[
                        {required: true, message: '请输入产品原价', trigger: 'blur'}
                    ],productName:[
                        {required: true, message: '请输入产品名称', trigger: 'blur'}
                    ],validity:[
                        {required: true, message: '请选择有效期', trigger: 'blur'}
                    ]
				},
				//编辑界面数据
				editForm: {
                    operatoruid: '',
                    provinceuuid: '',
                    busuuid: '',
                    user: {useruuid:''},
                    productCode: '',
                    upfacevalue: '',
                    discount: '1',
                    fastchargetype: '1',
                    remark: '',
                    useruuid:'',
                    upfailnum:1,
                    uptimeinterva:1,
                    upprouuid:'',
                    productName:'',
                    price:'0',
                    discountAmount:'',
                    validity:'',
                    deduct:'',
                    deductAmount:''
                },

				addFormVisible: false,//新增界面是否显示
				addLoading: false,
				addFormRules: {
                    operatoruid: [
						{ required: true, message: '请选择运营商', trigger: 'blur' }
					],
                    provinceuuid: [
                        { required: true, message: '请选择省份', trigger: 'blur' }
                    ],
                    busuuid: [
                        { required: true, message: '请选择业务类型', trigger: 'blur' }
                    ],
                    useruuid: [
                        { required: true, message: '请选择渠道商', trigger: 'blur' }
                    ],
                    upfacevalue :[
                        { required: true, message: '请输入产品面值,如果是话费则是对应的充值原价,如果是流量则是xxM', trigger: 'blur' }
                    ],
                    productCode :[
                        { required: true, message: '请输入产品名称', trigger: 'blur' }
                    ],
                    discount :[
                        { required: true, message: '请输入产品折扣', trigger: 'blur' },
                        {min: 1, max: 8, message: '长度在 1 到 3 个字符', trigger: 'blur'},
                    ],
                    fastchargetype :[
                        { required: true, message: '请选择快慢充类型', trigger: 'blur' }
                    ],price:[
                        {required: true, message: '请输入产品原价', trigger: 'blur'}
                    ],productName:[
                        {required: true, message: '请输入产品名称', trigger: 'blur'}
                    ],validity:[
                        {required: true, message: '请选择有效期', trigger: 'blur'}
                    ]
				},
				//新增界面数据
				addForm: {
                    operatoruid: '',
                    provinceuuid: '',
                    busuuid: '',
                    user: {useruuid:''},
                    productCode: '',
                    upfacevalue: '',
                    discount: '1',
                    fastchargetype: '1',
                    remark: '',
                    useruuid:'',
                    upfailnum:1,
                    productName:'',
                    validity:'',
                    uptimeinterva:1,
                    price:'0',
                    discountAmount:'',
                    deduct:'1',
                    deductAmount:''
				},
				//下拉数据
				operator :[],
             	info:[],
                bus:[],
                users:[],
				ups:[]
			}
		},
		methods: {
            fastchargevalidity:function(row, column){
                return (row.validity === "1") ? "30天" : (row.validity === "2") ?  "当月" : "未知";
            },
            productType: function (row, column) {
                return (row.businessType.busname == "手机") ? (row.upfacevalue + '话费') : ( row.businessType.busname == "固话") ?  (row.upfacevalue + '话费') :(row.upfacevalue + 'M');
            },
            fastchargetype: function (row, column) {
				return row.fastchargetype == 1 ? '快充' : row.fastchargetype == 0 ? '慢充' : '未知';
			},
            status: function (row, column) {
                return row.status == "1" ? '正常' : row.status == "0" ? '删除' :  row.status == "2"  ? "禁用" :  '未知';
            },

            findPageProduct() {
				let para = {
                    start: this.start,
                    pageSize:this.pageSize,
                    provinceuuid: this.filters.provinceuuid == "0" ? "" :this.filters.provinceuuid ,
                    operatoruid:this.filters.operatoruid == "0" ? "" :this.filters.operatoruid,
                    busuuid:this.filters.busuuid == "0" ? "" :this.filters.busuuid ,
                    useruuid:this.filters.useruuid == "0" ? "" :this.filters.useruuid ,
                    productCode:this.filters.productCode ,
                    fastchargetype:'',
                    upfacevalue:this.filters.upfacevalue ,
                    validity:this.filters.validity == "0" ? "" :this.filters.validity
				};
				this.listLoading = true;
                findPageProduct(para).then((datas) => {
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else if(data.result) {
                        this.products = data.result;
                        this.total = data.totalCount;
                    }
					this.listLoading = false;
				});
			},
            exportUpProduct(){
                let para = {
                    provinceuuid:this.filters.provinceuuid == "0" ? "" :this.filters.provinceuuid,
                    operatoruid:this.filters.operatoruid == "0" ? "" :this.filters.operatoruid,
                    busuuid:this.filters.busuuid == "0" ? "" :this.filters.busuuid ,
                    useruuid:this.filters.useruuid == "0" ? "" :this.filters.useruuid ,
                    productCode:this.filters.productCode ,
                    fastchargetype:'',
                    upfacevalue:''
                };
                this.listLoading = true;
                exportUpProduct(para).then((datas) => {
                    let {message, code, data} = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        window.open(data.path);
                    }
                    this.listLoading = false;
                });
			},
            discountChangeAdd:function () {
                this.addForm.discountAmount = (this.addForm.discount * this.addForm.price).toFixed(5);
                this.addForm.deductAmount = (this.addForm.deduct * this.addForm.price).toFixed(5);
            },
            discountChangeEdit:function () {
                this.editForm.discountAmount = (this.editForm.discount * this.editForm.price).toFixed(5);
                this.editForm.deductAmount = (this.editForm.deduct * this.editForm.price).toFixed(5);
            },
            deductChangeAdd:function () {
                this.addForm.deductAmount = (this.addForm.deduct * this.addForm.price).toFixed(5);
            },deductChangeEdit:function () {
                this.editForm.deductAmount = (this.editForm.deduct * this.editForm.price).toFixed(5);
            },
			//删除
			handleDel: function (index, row) {
				this.$confirm('确认删除该记录吗?', '提示', {
					type: 'warning'
				}).then(() => {
					this.listLoading = true;
					//NProgress.start();
					let para = { id: row.id };
					removeUser(para).then((res) => {
						this.listLoading = false;
						//NProgress.done();
						this.$message({
							message: '删除成功',
							type: 'success'
						});
						this.findPageProduct();
					});
				}).catch(() => {

				});
			},
			handleEnable:function(index,row){
                this.$confirm('确认更新该产品状态吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    let para = {
                        upprouuid:row.upprouuid,
                        status : row.status == "2" ? "1" : "2",
                        useruuid:util.getUserUUid()
                    };
                    productEnable(para).then((res) => {
                        this.listLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '操作成功',
                            type: 'success'
                        });
                        this.findPageProduct();
                    });
                }).catch(() => {

                });
			},
			//显示编辑界面
			handleEdit: function (index, row) {
				this.editFormVisible = true;
                this.loadBasicInfo();
                let para = {
                    upprouuid:row.upprouuid
                };
                this.upfindlist();
                findOneUpProduct(para).then(datas =>{
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.editForm.operatoruid = data.operators.operatoruid;
                        this.editForm.provinceuuid = data.provincialInformation.provinceuuid;
                        this.editForm.busuuid = data.businessType.busuuid;
                        this.editForm.useruuid = data.user.useruuid;
                        this.editForm.fastchargetype =  data.fastchargetype+"";
                        this.editForm.productCode = data.productCode;
                        this.editForm.upfacevalue = data.upfacevalue;
                        this.editForm.discount = data.discount;
                        this.editForm.remark = data.remark;
                        this.editForm.upprouuid = data.upprouuid;
                        this.editForm.price = data.price;
                        this.editForm.discountAmount = data.discountAmount;
                        this.editForm.productName = data.productName;
                        this.editForm.validity = data.validity;
                        this.editForm.deduct = data.deduct;
                        this.editForm.deductAmount = data.deductAmount;
                    }
				});
			},
			loadBasicInfo:function(){
                let para = {
                    upprouuid:''
                };
                findOpeProBusShop(para).then(datas => {
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.operator = data.operator;
                        this.info =   data.info;
                        this.bus =   data.bus;
                    }
                }).catch(e =>{
                    this.listLoading = false;
            	});

                findAllUpShopInfo(para).then(datas => {
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.users =   data;
                    }
                }).catch(e =>{
                    this.listLoading = false;
            	});
			},
			//显示新增界面
			handleAdd: function () {
				this.addFormVisible = true;
				this.loadBasicInfo();
               	this.upfindlist();
			},
			upfindlist:function(){
                upfindlist().then(datas =>{
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.ups =   data;
                    }
                }).catch(e =>{
                    this.listLoading = false;
            	});
			},
			//编辑
			editSubmit: function () {
				this.$refs.editForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.editLoading = true;
							//NProgress.start();
							let para = Object.assign({}, this.editForm);
							if(para.discount){

							}
                            updateUpProduct(para).then((datas) => {
								this.editLoading = false;
                                let { message, code, data } = datas;
                                if (code !== "0") {
                                    this.$message({
                                        message: message,
                                        type: 'error'
                                    });
                                }
								this.$refs['editForm'].resetFields();
								this.editFormVisible = false;
								this.findPageProduct();
							}).catch(e =>{
                            	this.listLoading = false;
                    		});
						});
					}
				});
			},
			//新增
            addUpProduct: function () {
				this.$refs.addForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => {
							this.addLoading = true;
							let para = Object.assign({}, this.addForm);
                            addUpProduct(para).then((datas) => {
								this.addLoading = false;
                                let { message, code, data } = datas;
                                if (code !== "0") {
                                    this.$message({
                                        message: message,
                                        type: 'error'
                                    });
                                }
								this.findPageProduct();
							}).catch(e =>{
                            	this.listLoading = false;
							});;
						});
					}
				});
			}
		  ,handleCurrentChange:function(val){
                this.start = val - 1;
                this.findPageProduct();
            },
            handleSizeChange:function(val){
                this.pageSize = val;
                this.findPageProduct();
            },
            infochange:function(info){
                //根据省份查询商户
                this.addForm.useruuid = '';
				let para = {
                    provinceuuid: info
				};
                findByProvince(para).then(datas =>{
                    let { message, code, data } = datas;
                    if (code !== "0") {
                        this.$message({
                            message: message,
                            type: 'error'
                        });
                    } else {
                        this.users = data;
                    }
				}).catch(e =>{
                    this.listLoading = false;
				});
			},
            userChange:function(user){
                this.addForm.useruuid = user;
			}
		},
		mounted() {
		    this.loadBasicInfo();
			this.findPageProduct();
		}
	}

</script>

<style scoped>

</style>
